package com.ruoyi.asms.controller;

import com.ruoyi.asms.domain.AsmsMaintenanceChargeInfo;
import com.ruoyi.asms.service.IAsmsMaintenanceChargeInfoService;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.web.page.TableDataInfo;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.security.annotation.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

/**
 * 维护方用户负责信息Controller
 * 
 * @author yfkj
 * @date 2021-10-21
 */
@RestController
@RequestMapping("/asms/AsmsMaintenanceChargeInfo")
public class AsmsMaintenanceChargeInfoController extends BaseController
{
    @Autowired
    private IAsmsMaintenanceChargeInfoService asmsMaintenanceChargeInfoService;

    /**
     * 查询维护方用户负责信息列表
     */
    @PreAuthorize
    //@PreAuthorize(hasPermi = "asms:AsmsMaintenanceChargeInfo:list")
    @GetMapping("/list")
    public TableDataInfo list(AsmsMaintenanceChargeInfo asmsMaintenanceChargeInfo)
    {
        startPage();
        List<AsmsMaintenanceChargeInfo> list = asmsMaintenanceChargeInfoService.selectAsmsMaintenanceChargeInfoList(asmsMaintenanceChargeInfo);
        return getDataTable(list);
    }

    /**
     * 导出维护方用户负责信息列表
     */
    @PreAuthorize
    //@PreAuthorize(hasPermi = "asms:AsmsMaintenanceChargeInfo:export")
    @Log(title = "维护方用户负责信息", businessType = BusinessType.EXPORT)
    @PostMapping(value="/export", produces = "application/octet-stream")
    public void export(HttpServletResponse response, AsmsMaintenanceChargeInfo asmsMaintenanceChargeInfo) throws IOException
    {
        List<AsmsMaintenanceChargeInfo> list = asmsMaintenanceChargeInfoService.selectAsmsMaintenanceChargeInfoList(asmsMaintenanceChargeInfo);
        ExcelUtil<AsmsMaintenanceChargeInfo> util = new ExcelUtil<AsmsMaintenanceChargeInfo>(AsmsMaintenanceChargeInfo.class);
        util.exportExcel(response, list, "维护方用户负责信息数据");
    }

    /**
     * 获取维护方用户负责信息详细信息
     */
    @PreAuthorize
    //@PreAuthorize(hasPermi = "asms:AsmsMaintenanceChargeInfo:query")
    @GetMapping(value = "/{maintenanceChargeInfoId}")
    public AjaxResult getInfo(@PathVariable("maintenanceChargeInfoId") Long maintenanceChargeInfoId)
    {
        return AjaxResult.success(asmsMaintenanceChargeInfoService.selectAsmsMaintenanceChargeInfoByMaintenanceChargeInfoId(maintenanceChargeInfoId));
    }

    /**
     * 新增维护方用户负责信息
     */
    @PreAuthorize
    //@PreAuthorize(hasPermi = "asms:AsmsMaintenanceChargeInfo:add")
    @Log(title = "维护方用户负责信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AsmsMaintenanceChargeInfo asmsMaintenanceChargeInfo)
    {
        return toAjax(asmsMaintenanceChargeInfoService.insertAsmsMaintenanceChargeInfo(asmsMaintenanceChargeInfo));
    }

    /**
     * 修改维护方用户负责信息
     */
    @PreAuthorize
    //@PreAuthorize(hasPermi = "asms:AsmsMaintenanceChargeInfo:edit")
    @Log(title = "维护方用户负责信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AsmsMaintenanceChargeInfo asmsMaintenanceChargeInfo)
    {
        return toAjax(asmsMaintenanceChargeInfoService.updateAsmsMaintenanceChargeInfo(asmsMaintenanceChargeInfo));
    }

    /**
     * 删除维护方用户负责信息
     */
    @PreAuthorize
    //@PreAuthorize(hasPermi = "asms:AsmsMaintenanceChargeInfo:remove")
    @Log(title = "维护方用户负责信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{maintenanceChargeInfoIds}")
    public AjaxResult remove(@PathVariable Long[] maintenanceChargeInfoIds)
    {
        return toAjax(asmsMaintenanceChargeInfoService.deleteAsmsMaintenanceChargeInfoByMaintenanceChargeInfoIds(maintenanceChargeInfoIds));
    }
}
